# 流程控制

#使用if进行分支判断
score = int(input("请输入分数"))
grade = ''
if(score<60):
    grade = "不及格"
if(60<=score<80):
    grade = "及格"
if(80<=score<90):
    grade = "良好"
if(90<=score<=100):
    grade = "优秀"
print("分数是{0},等级是{1}".format(score,grade))

# 使用elif进行分支判断,根据输入的数值判断在第几象限
x = int(input("请输入 x 坐标"))
y = int(input("请输入 y 坐标"))

if(x==0 and y==0):print("原点")
elif(x==0):print("y 轴")
elif(y==0):print("x 轴")
elif(x>0 and y>0):print("第一象限")
elif(x<0 and y>0):print("第二象限")
elif(x<0 and y<0):print("第三象限")
else:
    print("第四象限")

# for循环
sum_all = 0
sum_odd = 0  #100以内的奇数和
sum_even = 0  #100以内的偶数和
for x in range(101):
    sum_all += x
    if x%2==1:
        sum_odd += x
    else:
        sum_even += x
print("1-100累加总和{0},奇数和{1},偶数和{2}".format(sum_all,sum_odd,sum_even))

# while循环
num = 0
while num<=10:
    print(num)
    num += 1

# 遍历字符串
for i in "hello11 world":
    print(i)

# break语句
while True:
    a = input("请输入一个字符（输入 Q 或 q 结束）")
    if a.upper()=='Q':
        print("循环结束，退出")
        break
    else:
        print(a)

# continue 语句
empNum = 0
salarySum= 0
salarys = []
while True:
    s = input("请输入员工的薪资（按 Q 或 q 结束）")
    if s.upper() == 'Q':
        print("录入完成，退出")
        break
    if float(s) < 0:
        continue
    empNum += 1
    salarys.append(float(s))
    salarySum += float(s)

print("员工数{0}".format(empNum))
print("录入薪资：",salarys)
print("平均薪资{0}".format(salarySum/empNum))

# while、for 循环可以附带一个 else 语句（可选）。如果 for、while 语句没有被 break 语句结束，则会执行 else 子句，否则不执行
salarySum= 0
salarys = []
for i in range(4):
    s = input("请输入一共 4 名员工的薪资（按 Q 或 q 中途结束）")
    if s.upper()=='Q':
        print("录入完成，退出")
        break
    if float(s)<0:
        continue
    salarys.append(float(s))
    salarySum += float(s)
else:
    print("您已经全部录入 4 名员工的薪资")

print("录入薪资：",salarys)
print("平均薪资{0}".format(salarySum/4))










